package com.bayihouse.model.vo;


import com.baomidou.mybatisplus.annotation.TableId;
import com.bayihouse.model.entity.Tempermit;
import com.bayihouse.utils.MyDateUtils;
import com.bayihouse.utils.MyObjectUtils;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

@Data
public class TempermitVO implements Serializable {
    private static final long serialVersionUID = 6612157990345017724L;


    /**
     * 暂住证编号
     */
    @TableId
    private Long id;

    /**
     * 社区名称
     */
    private String comuntyname;

    /**
     * 用户名称
     */
    private String name;

    /**
     * 0表示外省，1表示内省
     */
    private Integer category;

    /**
     * 用户电话
     */
    private String telephone;

    /**
     * 居住地址
     */
    private String address;

    /**
     * 办理日期
     */
    private String createtime;

    /**
     * 截止日期
     */
    private String dealtime;

    /**
     * 0-代表生效，1-代表过期 2-代表注销
     */
    private String status;

    /**
     * 备注
     */
    private String detail;


    public static TempermitVO objToVo(Tempermit tempermit) {
        TempermitVO tempermitVO = new TempermitVO();
        BeanUtils.copyProperties(tempermit, tempermitVO);
        tempermitVO.setCreatetime(MyDateUtils.dateToString(tempermit.getCreatetime()));
        tempermitVO.setDealtime(MyDateUtils.dateToString(tempermit.getDealtime()));
        switch (tempermit.getStatus()) {
            case 0:
                tempermitVO.setStatus("已生效");
                break;
            case 1:
                tempermitVO.setStatus("已过期");
                break;
            case 2:
                tempermitVO.setStatus("已注销");
                break;
            default:
                tempermitVO.setStatus("未知状态");
        }
        return tempermitVO;
    }
}
